<?php
namespace Controller;
use Kuyuan\WqCore\controller\Controller;
use Model\SettingMessageModel;

/**
 * 模板消息&&订阅消息配置
 * Class Media
 * @package Controller
 */
class SettingMessage extends Controller
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 获取参数
     */
    public function find()
    {
        $_setting = SettingMessageModel::where("uniacid",$this->_uniacid)
                                    ->cache(!KUYUAN_DEBUG)
                                    ->find();
        if(!$_setting){
            SettingMessageModel::create(
                array(
                    "uniacid"=>$this->_uniacid
                )
            );
            return $this->find();
        }
        return $_setting;
    }

    /**
     * 设置参数
     * @param array $_data 修改的数据
     * @return mixed
     */
    public function set($_data)
    {
        return SettingMessageModel::where("uniacid",$this->_uniacid)
                ->update($_data);
    }

}